<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="合同编号" prop="userName">
        <el-input v-model="queryParams.contNo" placeholder="请输入合同编号" clearable style="width: 240px" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
      <el-form-item style="float: right;">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:user:add']">新增</el-button>
        <!-- <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['system:user:edit']">修改</el-button> -->
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['system:user:remove']">删除</el-button>
        <el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport" v-hasPermi="['system:user:import']">导入</el-button>
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system:user:export']">导出</el-button>
        <!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar> -->
      </el-form-item>
    </el-form>
    <el-row :gutter="20">
      <!--部门数据-->
      <el-col :span="4" :xs="24">
        <div class="head-container">
          <el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false" :filter-node-method="filterNode" ref="tree" node-key="id" default-expand-all highlight-current @node-click="handleNodeClick" />
        </div>
      </el-col>
      <!--用户数据-->
      <el-col :span="20" :xs="24">
        <!-- <bid-sum v-show="showTabKey == '0'"></bid-sum> -->
        <bid-abc v-show="showTabKey == 'ABC'" :key="ABCKey" ref="comAbc" :codeListA="codeListA" :codeListB="codeListB" :codeListC="codeListC" :taxRateList="taxRateList" :contNo="queryParams.contNo" @change="handleChange($event)"></bid-abc>
        <bid-d v-show="showTabKey == 'D'" :key="DKey" ref="comD" :codeListD="codeListD" :taxRateList="taxRateList" :contNo="queryParams.contNo" @change="handleChange($event)"></bid-d>
        <bid-e v-show="showTabKey == 'E'" :key="EKey" ref="comE" :codeListE="codeListE" :taxRateList="taxRateList" :contNo="queryParams.contNo" @change="handleChange($event)"></bid-e>
        <bid-f v-show="showTabKey == 'F'" :key="FKey" ref="comF" :codeListF="codeListF" :taxRateList="taxRateList" :contNo="queryParams.contNo" @change="handleChange($event)"></bid-f>
        <bid-g v-show="showTabKey == 'G'" :key="GKey" ref="comG" :codeListG="codeListG" :taxRateList="taxRateList" :contNo="queryParams.contNo" @change="handleChange($event)"></bid-g>
      </el-col>
    </el-row>
    <!-- 添加或修改实施预算-投标-实施abc对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="formABC" :model="formABC" :rules="rules" label-width="120px" v-if="showTabKey == 'ABC'">
        <el-row>
          <el-col :span="12">
            <el-form-item label="合同编号" prop="contNo">
              <el-select v-model="formABC.contNo" placeholder="请选择合同编号" :disabled="isReadOnly" style="width:260px">
                <el-option v-for="item in salecontList" :key="item.contractNo" :label="item.contractNo" :value="item.contractNo"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="a代码" prop="acode">
              <el-select v-model="formABC.acode" placeholder="请选择a代码" :disabled="isReadOnly" style="width:260px">
                <el-option v-for="item in codeListA" :key="item.code" :label="item.code" :value="item.code"></el-option>
              </el-select>
              <!-- <el-input v-model="formABC.aCode" placeholder="请输入a代码" /> -->
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="b代码" prop="bcode">
              <el-select v-model="formABC.bcode" placeholder="请选择b代码" :disabled="isReadOnly" style="width:260px">
                <el-option v-for="item in codeListB" :key="item.code" :label="item.code" :value="item.code"></el-option>
              </el-select>
              <!-- <el-input v-model="formABC.bCode" placeholder="请输入b代码" /> -->
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="c代码" prop="ccode">
              <el-select v-model="formABC.ccode" placeholder="请选择c代码" :disabled="isReadOnly" style="width:260px">
                <el-option v-for="item in codeListC" :key="item.code" :label="item.code" :value="item.code"></el-option>
              </el-select>
              <!-- <el-input v-model="formABC.cCode" placeholder="请输入c代码" /> -->
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="类别名称" prop="name">
              <el-input v-model="formABC.name" placeholder="请输入类别名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="描述" prop="mateDesc">
              <el-input v-model="formABC.mateDesc" placeholder="请输入描述" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="规格" prop="specs">
              <el-input v-model="formABC.specs" placeholder="请输入规格" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="formABC.remark" placeholder="请输入备注" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="区域" prop="region">
              <el-input v-model="formABC.region" placeholder="请输入区域" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="材质" prop="mateQuality">
              <el-input v-model="formABC.mateQuality" placeholder="请输入材质" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="单位" prop="unit">
              <el-input v-model="formABC.unit" placeholder="请输入单位" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="数量" prop="num">
              <el-input type="number" v-model="formABC.num" placeholder="请输入数量" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="AB项成本单价" prop="abUnitPrice">
              <el-input type="number" v-model="formABC.abUnitPrice" placeholder="请输入AB项成本单价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="AB项成本总价" prop="abTotalPrice">
              <el-input type="number" v-model="formABC.abTotalPrice" placeholder="请输入AB项成本总价" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="AB项税率" prop="abTax">
              <!-- <el-select ref="itemNoRef" v-model="formABC.abTax" placeholder="请选择AB项税率" :disabled="isReadOnly"
                style="width: 260px;">
                <el-option v-for="item in taxRateList" :key="item.value" :label="item.label"
                  :value="item.value"></el-option>
              </el-select> -->
              <el-input type="number" v-model="formABC.abTax" placeholder="请输入AB项税率" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="AB项进项税" prop="abInputTax">
              <!-- <el-select ref="itemNoRef" v-model="formABC.abInputTax" placeholder="请选择AB项进项税" :disabled="isReadOnly"
                style="width: 260px;">
                <el-option v-for="item in taxRateList" :key="item.value" :label="item.label"
                  :value="item.value"></el-option>
              </el-select> -->
              <el-input type="number" v-model="formABC.abInputTax" placeholder="请输入AB项进项税" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="C项成本单价" prop="cunitPrice">
              <el-input type="number" v-model="formABC.cunitPrice" placeholder="请输入C项成本单价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="C项成本总价" prop="ctotalPrice">
              <el-input type="number" v-model="formABC.ctotalPrice" placeholder="请输入C项成本总价" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="C项税率" prop="ctax">
              <el-select ref="itemNoRef" v-model="formABC.ctax" placeholder="请选择C项税率" :disabled="isReadOnly" style="width: 260px;">
                <el-option v-for="item in taxRateList" :key="item.value" :label="item.label" :value="item.value"></el-option>
              </el-select>
              <!-- <el-input type="number" v-model="formABC.cTax" placeholder="请输入C项税率" /> -->
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="C项进项税" prop="cinputTax">
              <!-- <el-select ref="itemNoRef" v-model="formABC.cinputTax" placeholder="请选择C项进项税" :disabled="isReadOnly"
                style="width: 260px;">
                <el-option v-for="item in taxRateList" :key="item.value" :label="item.label"
                  :value="item.value"></el-option>
              </el-select> -->
              <el-input type="number" v-model="formABC.cinputTax" placeholder="请输入C项进项税" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-form ref="formD" :model="formD" :rules="rules" label-width="120px" v-if="showTabKey == 'D'">
        <el-row>
          <el-col :span="12">
        <el-form-item label="合同编号" prop="contNo">
          <el-select v-model="formD.contNo" placeholder="请选择合同编号" :disabled="isReadOnly" style="width: 260px">
            <el-option v-for="item in salecontList" :key="item.contractNo" :label="item.contractNo" :value="item.contractNo"></el-option>
          </el-select>
          <!-- <el-input v-model="formD.contNo" placeholder="请输入合同编号" /> -->
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="d代码" prop="dcode">
          <el-select v-model="formD.dcode" placeholder="请选择d代码" :disabled="isReadOnly" style="width:260px">
                <el-option v-for="item in codeListD" :key="item.code" :label="item.code" :value="item.code"></el-option>
              </el-select>
              <!-- <el-input v-model="formD.dCode" placeholder="请输入d代码" /> -->
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="类别名称" prop="name">
          <el-input v-model="formD.name" placeholder="请输入类别名称" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="规格" prop="specs">
          <el-input v-model="formD.specs" placeholder="请输入规格" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="数量" prop="num">
          <el-input type="number" v-model="formD.num" placeholder="请输入数量" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="单位" prop="unit">
          <el-input v-model="formD.unit" placeholder="请输入单位" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="d项成本单价" prop="dunitPrice">
          <el-input type="number" v-model="formD.dunitPrice" placeholder="请输入d项成本单价" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="d项成本总价" prop="dtotalPrice">
          <el-input type="number" v-model="formD.dtotalPrice" placeholder="请输入d项成本总价" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="d项税率" prop="dtax">
          <el-select ref="itemNoRef" v-model="formD.dtax" placeholder="请选择d项税率" :disabled="isReadOnly" style="width: 260px;">
                <el-option v-for="item in taxRateList" :key="item.value" :label="item.label" :value="item.value"></el-option>
              </el-select>
              <!-- <el-input type="number" v-model="formD.dTax" placeholder="请输入d项税率" /> -->
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="d项进项税" prop="dinputTax">
          <!-- <el-select ref="itemNoRef" v-model="formD.dinputTax" placeholder="请选择d项进项税" :disabled="isReadOnly"
                style="width: 260px;">
                <el-option v-for="item in taxRateList" :key="item.value" :label="item.label"
                  :value="item.value"></el-option>
              </el-select> -->
              <el-input type="number" v-model="formD.dinputTax" placeholder="请输入d项进项税" />
        </el-form-item>
</el-col>
        </el-row>
      </el-form>
      <el-form ref="formE" :model="formE" :rules="rules" label-width="120px" v-if="showTabKey == 'E'">
        <el-row>
          <el-col :span="12">
        <el-form-item label="合同编号" prop="contNo">
          <el-select v-model="formE.contNo" placeholder="请选择合同编号" :disabled="isReadOnly" style="width: 260px;">
            <el-option v-for="item in salecontList" :key="item.contractNo" :label="item.contractNo" :value="item.contractNo"></el-option>
          </el-select>
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="e代码" prop="ecode">
          <el-select v-model="formE.ecode" placeholder="请选择e代码" :disabled="isReadOnly" style="width:260px">
                <el-option v-for="item in codeListE" :key="item.code" :label="item.code" :value="item.code"></el-option>
              </el-select>
              <!-- <el-input v-model="formE.eCode" placeholder="请输入e代码" /> -->
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="类别名称" prop="name">
          <el-input v-model="formE.name" placeholder="请输入类别名称" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="规格" prop="specs">
          <el-input v-model="formE.specs" placeholder="请输入规格" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="数量" prop="num">
          <el-input type="number" v-model="formE.num" placeholder="请输入数量" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="单位" prop="unit">
          <el-input v-model="formE.unit" placeholder="请输入单位" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="e项成本单价" prop="eunitPrice">
          <el-input v-model="formE.eunitPrice" placeholder="请输入e项成本单价" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="e项成本总价" prop="etotalPrice">
          <el-input v-model="formE.etotalPrice" placeholder="请输入e项成本总价" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="e项税率" prop="etax">
          <el-select ref="itemNoRef" v-model="formE.etax" placeholder="请选择e项税率" :disabled="isReadOnly" style="width: 260px;">
                <el-option v-for="item in taxRateList" :key="item.value" :label="item.label" :value="item.value"></el-option>
              </el-select>
              <!-- <el-input v-model="formE.eTax" placeholder="请输入e项税率" /> -->
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="e项进项税" prop="einputTax">
          <!-- <el-select ref="itemNoRef" v-model="formE.einputTax" placeholder="请选择e项进项税" :disabled="isReadOnly"
                style="width: 260px;">
                <el-option v-for="item in taxRateList" :key="item.value" :label="item.label"
                  :value="item.value"></el-option>
              </el-select> -->
              <el-input v-model="formE.eInputTax" placeholder="请输入e项进项税" />
        </el-form-item>
</el-col>
        </el-row>
      </el-form>
      <el-form ref="formF" :model="formF" :rules="rules" label-width="120px" v-if="showTabKey == 'F'">
        <el-row>
          <el-col :span="12">
        <el-form-item label="合同编号" prop="contNo">
          <el-select v-model="formF.contNo" placeholder="请选择合同编号" :disabled="isReadOnly" style="width: 260px;">
            <el-option v-for="item in salecontList" :key="item.contractNo" :label="item.contractNo" :value="item.contractNo"></el-option>
          </el-select>
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="设计进项总计" prop="designInAmount">
          <el-input v-model="formF.designInAmount" placeholder="请输入设计进项总计" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="设计进项税率" prop="designInTax">
          <el-select ref="itemNoRef" v-model="formF.designInTax" placeholder="请选择设计进项税率" :disabled="isReadOnly" style="width: 260px;">
                <el-option v-for="item in taxRateList" :key="item.value" :label="item.label" :value="item.value"></el-option>
              </el-select>
              <!-- <el-input v-model="formF.designInTax" placeholder="请输入设计进项税率" /> -->
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="设计进项税费" prop="designInTaxFee">
          <el-input v-model="formF.designInTaxFee" placeholder="请输入设计进项税费" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="材料进项总计" prop="materialInAmount">
          <el-input v-model="formF.materialInAmount" placeholder="请输入材料进项总计" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="材料进项税率" prop="materialInTax">
          <el-select ref="itemNoRef" v-model="formF.materialInTax" placeholder="请选择材料进项税率" :disabled="isReadOnly" style="width: 260px;">
                <el-option v-for="item in taxRateList" :key="item.value" :label="item.label" :value="item.value"></el-option>
              </el-select>
              <!-- <el-input v-model="formF.materialInTax" placeholder="请输入材料进项税率" /> -->
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="材料进项税费" prop="materialInTaxFee">
          <el-input v-model="formF.materialInTaxFee" placeholder="请输入材料进项税费" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="工程进项总计" prop="proInAmount">
          <el-input v-model="formF.proInAmount" placeholder="请输入工程进项总计" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="工程进项税率" prop="proInTax">
          <el-select ref="itemNoRef" v-model="formF.proInTax" placeholder="请选择工程进项税率" :disabled="isReadOnly" style="width: 260px;">
                <el-option v-for="item in taxRateList" :key="item.value" :label="item.label" :value="item.value"></el-option>
              </el-select>
              <!-- <el-input v-model="formF.proInTax" placeholder="请输入工程进项税率" /> -->
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="工程进项税费" prop="proInTaxFee">
          <el-input v-model="formF.proInTaxFee" placeholder="请输入工程进项税费" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="进项总额" prop="inTotalAmount">
          <el-input v-model="formF.inTotalAmount" placeholder="请输入进项总额" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="进项总税额" prop="inTotalTaxAmount">
          <el-input v-model="formF.inTotalTaxAmount" placeholder="请输入进项总税额" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="设计出项总计" prop="designOutAmount">
          <el-input v-model="formF.designOutAmount" placeholder="请输入设计出项总计" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="设计出项税率" prop="designOutTax">
          <el-select ref="itemNoRef" v-model="formF.designOutTax" placeholder="请选择设计出项税率" :disabled="isReadOnly" style="width: 260px;">
                <el-option v-for="item in taxRateList" :key="item.value" :label="item.label" :value="item.value"></el-option>
              </el-select>
              <!-- <el-input v-model="formF.designOutTax" placeholder="请输入设计出项税率" /> -->
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="设计出项税费" prop="designOutTaxFee">
          <el-input v-model="formF.designOutTaxFee" placeholder="请输入设计出项税费" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="材料出项总计" prop="materialOutAmount">
          <el-input v-model="formF.materialOutAmount" placeholder="请输入材料出项总计" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="材料出项税率" prop="materialOutTax">
          <el-select ref="itemNoRef" v-model="formF.materialOutTax" placeholder="请选择材料出项税率" :disabled="isReadOnly" style="width: 260px;">
                <el-option v-for="item in taxRateList" :key="item.value" :label="item.label" :value="item.value"></el-option>
              </el-select>
              <!-- <el-input v-model="formF.materialOutTax" placeholder="请输入材料出项税率" /> -->
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="材料出项总计" prop="materialOutTaxFee">
          <el-input v-model="formF.materialOutTaxFee" placeholder="请输入材料出项总计" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="工程出项总计" prop="proOutAmount">
          <el-input v-model="formF.proOutAmount" placeholder="请输入工程出项总计" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="工程出项税率" prop="proOutTax">
          <el-select ref="itemNoRef" v-model="formF.proOutTax" placeholder="请选择工程出项税率" :disabled="isReadOnly" style="width: 260px;">
                <el-option v-for="item in taxRateList" :key="item.value" :label="item.label" :value="item.value"></el-option>
              </el-select>
              <!-- <el-input v-model="formF.proOutTax" placeholder="请输入工程出项税率" /> -->
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="工程出项税费" prop="proOutTaxFee">
          <el-input v-model="formF.proOutTaxFee" placeholder="请输入工程出项税费" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="出项总额" prop="outTotalAmount">
          <el-input v-model="formF.outTotalAmount" placeholder="请输入出项总额" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="出项总税额" prop="outTotalTaxAmount">
          <el-input v-model="formF.outTotalTaxAmount" placeholder="请输入出项总税额" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="增值税" prop="addedTax">
<!-- <el-select ref="itemNoRef" v-model="formF.addedTax" placeholder="请选择增值税" :disabled="isReadOnly"
                style="width: 260px;">
                <el-option v-for="item in taxRateList" :key="item.value" :label="item.label"
                  :value="item.value"></el-option>
              </el-select> -->
          <el-input v-model="formF.addedTax" placeholder="请输入增值税" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="企业所得税" prop="corporateIncomeTax">
<!-- <el-select ref="itemNoRef" v-model="formF.corporateIncomeTax" placeholder="请选择企业所得税" :disabled="isReadOnly"
                style="width: 260px;">
                <el-option v-for="item in taxRateList" :key="item.value" :label="item.label"
                  :value="item.value"></el-option>
              </el-select> -->
          <el-input v-model="formF.corporateIncomeTax" placeholder="请输入企业所得税" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="其他税" prop="otherTax">
<!-- <el-select ref="itemNoRef" v-model="formF.otherTax" placeholder="请选择其他税" :disabled="isReadOnly"
                style="width: 260px;">
                <el-option v-for="item in taxRateList" :key="item.value" :label="item.label"
                  :value="item.value"></el-option>
              </el-select> -->
          <el-input v-model="formF.otherTax" placeholder="请输入其他税" />
        </el-form-item>
</el-col>
        </el-row>
        <el-form-item label="税费总计" prop="taxTotalFee">
          <el-input v-model="formF.taxTotalFee" placeholder="请输入税费总计" />

        </el-form-item>
      </el-form>
      <el-form ref="formG" :model="formG" :rules="rules" label-width="120px" v-if="showTabKey == 'G'">
<el-row>
          <el-col :span="12">
        <el-form-item label="合同编号" prop="contNo">
          <el-select v-model="formG.contNo" placeholder="请选择合同编号" :disabled="isReadOnly" style="width: 260px;">
            <el-option v-for="item in salecontList" :key="item.contractNo" :label="item.contractNo" :value="item.contractNo"></el-option>
          </el-select>
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="代码" prop="gcode">
          <el-select v-model="formG.gcode" placeholder="请选择代码" :disabled="isReadOnly" style="width:260px">
                <el-option v-for="item in codeListG" :key="item.code" :label="item.code" :value="item.code"></el-option>
              </el-select>
              <!-- <el-input v-model="formG.gCode" placeholder="请输入代码" /> -->
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="类别名称" prop="name">
          <el-input v-model="formG.name" placeholder="请输入类别名称" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="A" prop="anum">
          <el-input v-model="formG.anum" placeholder="请输入A" @blur="formG.abc = formG.aNum * formG.bNum * formG.cNum" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="A单位" prop="aunit">
          <el-input v-model="formG.aunit" placeholder="请输入A单位" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="B" prop="bnum">
          <el-input v-model="formG.bnum" placeholder="请输入B" @blur="formG.abc = formG.aNum * formG.bNum * formG.cNum" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="B单位" prop="bunit">
          <el-input v-model="formG.bunit" placeholder="请输入B单位" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="C" prop="cnum">
          <el-input v-model="formG.cnum" placeholder="请输入C" @blur="formG.abc = formG.aNum * formG.bNum * formG.cNum" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="C单位" prop="cunit">
          <el-input v-model="formG.cunit" placeholder="请输入C单位" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="A*B*C" prop="abc">
          <el-input v-model="formG.abc" placeholder="请输入A*B*C" />
        </el-form-item>
</el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="投标金额" prop="amount">
          <el-input v-model="formG.amount" placeholder="请输入投标金额" />
        </el-form-item>
</el-col>
          <el-col :span="12">
        <el-form-item label="税率" prop="tax">
          <el-select ref="itemNoRef" v-model="formG.tax" placeholder="请选择税率" :disabled="isReadOnly" style="width: 260px;">
                <el-option v-for="item in taxRateList" :key="item.value" :label="item.label" :value="item.value"></el-option>
              </el-select>
              <!-- <el-input v-model="formG.tax" placeholder="请输入税率" /> -->
        </el-form-item>
</el-col>
        </el-row>
        <el-form-item label="进项税额" prop="inTaxAmount">
          <el-input v-model="formG.inTaxAmount" placeholder="请输入进项税额" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 实施预算——投标导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" action="" :http-request="importData" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :auto-upload="false" drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的设计预算与设计支出数据
          </div>
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
    listUser,
    getUser,
    delUser,
    addUser,
    updateUser,
    resetUserPwd,
    changeUserStatus,
    deptTreeSelect
} from "@/api/system/user";
import {
    listSalecont
} from "@/api/erp/salecont";
import {
    addAbc
} from "@/api/bid/abc";
import {
    addD
} from "@/api/bid/d";
import {
    addE
} from "@/api/bid/e";
import {
    addF
} from "@/api/bid/f";
import {
    addG
} from "@/api/bid/g";
import {
    getToken
} from "@/utils/auth";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import BidAbc from "./abc/index";
import BidD from "./d/index";
import BidE from "./e/index";
import BidF from "./f/index";
import BidG from "./g/index";
import BidSum from "./sum/index";
import { getCodeList } from "@/api/etc/purchasereq";
import axios from 'axios'

import {
    getChildListByPid
} from "@/api/bid/abc";
import {
    mapGetters
} from 'vuex'
// import { listD, getD, delD, addD, updateD, disableD  } from "@/api/bid/d";
// import { listE, getE, delE, addE, updateE, disableE  } from "@/api/bid/e";
// import { listF, getF, delF, addF, updateF, disableF  } from "@/api/bid/f";
// import { listG, getG, delG, addG, updateG, disableG  } from "@/api/bid/g";
export default {
  name: "User",
  dicts: ['sys_normal_disable', 'sys_user_sex'],
  components: {
        Treeselect,
        BidAbc,
        BidD,
        BidE,
        BidF,
        BidG,
        BidSum
    },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户表格数据
      userList: null,
      // 弹出层标题
      title: "",
      // 部门树选项
      deptOptions: [{
        id: 0,
        name: '实施预算——实施',
        children: [{
          id: 'ABC',
          name: 'ABC项'
        }, {
          id: 'D',
          name: 'D项'
        }, {
          id: 'E',
          name: 'E项'
        }, {
          id: 'F',
          name: 'F项'
        }, {
          id: 'G',
          name: 'G项'
        }]
      }],
      // 是否显示弹出层
      open: false,
      // 部门名称
      deptName: undefined,
      // 默认密码
      initPassword: undefined,
      // 日期范围
      dateRange: [],
      // 岗位选项
      postOptions: [],
      // 角色选项
      roleOptions: [],
      // 表单参数
      form: {},
      defaultProps: {
        children: "children",
        label: "name"
      },
      // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: {
                    Authorization: "Bearer " + getToken()
                },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/bid/abc/importData"
      },
      showTabKey: 'ABC',
      showDialogKey: 'ABC',
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        busType: 2,
        contNo: null
      },
      // 列信息
      columns: [{
                    key: 0,
                    label: `用户编号`,
                    visible: true
                },
        {
                    key: 1,
                    label: `用户名称`,
                    visible: true
                },
        {
                    key: 2,
                    label: `用户昵称`,
                    visible: true
                },
        {
                    key: 3,
                    label: `部门`,
                    visible: true
                },
        {
                    key: 4,
                    label: `手机号码`,
                    visible: true
                },
        {
                    key: 5,
                    label: `状态`,
                    visible: true
                },
        {
                    key: 6,
                    label: `创建时间`,
                    visible: true
                }
      ],
      // 表单校验
      rules: {
        contNo: [{
                    required: true,
                    message: "合同编号不能为空",
                    trigger: "blur"
                }]
      },
      formABC: {
        "abInputTax": null,
        "abTax": null,
        "abTotalPrice": null,
        "abUnitPrice": null,
        "acode": "",
        "bcode": "",
        "busType": 2,
        "ccode": "",
        "cinputTax": null,
        "contNo": "",
        "ctax": null,
        "ctotalPrice": null,
        "cunitPrice": null,
        "id": "",
        "isSum": 0,
        "mateDesc": "",
        "mateQuality": "",
        "name": "",
        "num": null,
        "region": "",
        "remark": "",
        "specs": "",
        "unit": ""
      },
      formD: {
        "busType": 2,
        "contNo": "",
        "dcode": "",
        "dinputTax": null,
        "dtax": null,
        "dtotalPrice": null,
        "dunitPrice": null,
        "id": "",
        "name": "",
        "num": null,
        "specs": "",
        "unit": ""
      },
      formE: {
        "busType": 2,
        "contNo": "",
        "ecode": "",
        "einputTax": null,
        "etax": null,
        "etotalPrice": null,
        "eunitPrice": null,
        "id": "",
        "name": "",
        "num": null,
        "specs": "",
        "unit": ""
      },
      formF: {
        "addedTax": null,
        "busType": 2,
        "contNo": "",
        "corporateIncomeTax": null,
        "designInAmount": null,
        "designInTax": null,
        "designInTaxFee": null,
        "designOutAmount": null,
        "designOutTax": null,
        "designOutTaxFee": null,
        "id": "",
        "inTotalAmount": null,
        "inTotalTaxAmount": null,
        "materialInAmount": null,
        "materialInTax": null,
        "materialInTaxFee": null,
        "materialOutAmount": null,
        "materialOutTax": null,
        "materialOutTaxFee": null,
        "otherTax": null,
        "outTotalAmount": null,
        "outTotalTaxAmount": null,
        "proInAmount": null,
        "proInTax": null,
        "proInTaxFee": null,
        "proOutAmount": null,
        "proOutTax": null,
        "proOutTaxFee": null,
        "taxTotalFee": null
      },
      formG: {
        "abc": null,
        "amount": null,
        "anum": null,
        "aunit": "",
        "bnum": null,
        "bunit": null,
        "busType": 2,
        "cnum": null,
        "contNo": "",
        "cunit": "",
        "gcode": "",
        "id": "",
        "inTaxAmount": null,
        "name": "",
        "tax": null
      },
      salecontList: [],
      ABCKey: 0,
      DKey: 0,
      EKey: 0,
      FKey: 0,
      GKey: 0,
      codeListA: [],
      codeListB: [],
      codeListC: [],
      codeListD: [],
      codeListE: [],
      codeListG: []
    };
  },
  watch: {
    // 根据名称筛选部门树
    deptName(val) {
      this.$refs.tree.filter(val);
    }
  },
computed: {
    ...mapGetters(["taxRateList"])
  },
  created() {
    this.getChildListByPid(2);
    this.getChildListByPid(3);
    this.getChildListByPid(4);
      this.ABCKey++;
  },
  methods: {
    // 筛选节点
    filterNode(value, data) {
      if (!value) return true;
      return data.label.indexOf(value) !== -1;
    },
    // 节点单击事件
    handleNodeClick(data) {
      this.showTabKey = data.id
if (this.showTabKey == "ABC") {
                this.getChildListByPid(2);
                this.getChildListByPid(3);
                this.getChildListByPid(4);
                this.ABCKey++;
            } else if (this.showTabKey == "D") {
                this.getChildListByPid(5);
                this.DKey++;
            } else if (this.showTabKey == "E") {
                this.getChildListByPid(6);
                this.EKey++;
            } else if (this.showTabKey == "F") {
                this.FKey++;
            } else if (this.showTabKey == "G") {
                this.getChildListByPid(9);
                this.GKey++;
            }
    },
    // 用户状态修改
    handleStatusChange(row) {
      let text = row.status === "0" ? "启用" : "停用";
      this.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗？').then(function () {
        return changeUserStatus(row.userId, row.status);
      }).then(() => {
        this.$modal.msgSuccess(text + "成功");
      }).catch(function () {
        row.status = row.status === "0" ? "1" : "0";
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        userId: undefined,
        deptId: undefined,
        userName: undefined,
        nickName: undefined,
        password: undefined,
        phonenumber: undefined,
        email: undefined,
        sex: undefined,
        status: "0",
        remark: undefined,
        postIds: [],
        roleIds: []
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      if (this.showTabKey == "ABC") {
        this.ABCKey++;
      } else if (this.showTabKey == "D") {
        this.DKey++;
      } else if (this.showTabKey == "E") {
        this.EKey++;
      } else if (this.showTabKey == "F") {
        this.FKey++;
      } else if (this.showTabKey == "G") {
        this.GKey++;
      }
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.queryParams.deptId = undefined;
      this.$refs.tree.setCurrentKey(null);
      this.handleQuery();
    },
    // // 多选框选中数据
    // handleSelectionChange(selection) {
      //     this.ids = selection.map(item => item.userId);
      //     this.single = selection.length != 1;
      //     this.multiple = !selection.length;
    // },
    // 更多操作触发
    handleCommand(command, row) {
      switch (command) {
        case "handleResetPwd":
          this.handleResetPwd(row);
          break;
        case "handleAuthRole":
          this.handleAuthRole(row);
          break;
        default:
          break;
      }
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      if (this.showTabKey == "ABC") {
        this.title = "添加ABC项";
this.getChildListByPid(2);
        this.getChildListByPid(3);
        this.getChildListByPid(4);
      } else if (this.showTabKey == "D") {
        this.title = "添加D项";
this.getChildListByPid(5);
      } else if (this.showTabKey == "E") {
        this.title = "添加E项";
this.getChildListByPid(6);
      } else if (this.showTabKey == "F") {
        this.title = "添加F项";
      } else if (this.showTabKey == "G") {
        this.title = "添加G项";
this.getChildListByPid(9);
      }
      this.getSalecontList();

      // this.$nextTick(() => {
      //   // 在DOM更新之后执行的操作
      //   this.codeListA = this.getChildListByPid(2);
      //   this.codeListB = this.getChildListByPid(3);
      //   this.codeListC = this.getChildListByPid(4);
      //   console.log(1)
      // })

    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const userId = row.userId || this.ids;
      getUser(userId).then(response => {
        this.form = response.data;
        this.postOptions = response.posts;
        this.roleOptions = response.roles;
        this.$set(this.form, "postIds", response.postIds);
        this.$set(this.form, "roleIds", response.roleIds);
        this.open = true;
        this.title = "修改用户";
        this.form.password = "";
      });
    },
    /** 重置密码按钮操作 */
    handleResetPwd(row) {
      this.$prompt('请输入"' + row.userName + '"的新密码', "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        closeOnClickModal: false,
        inputPattern: /^.{5,20}$/,
        inputErrorMessage: "用户密码长度必须介于 5 和 20 之间"
      }).then(({
                value
            }) => {
        resetUserPwd(row.userId, value).then(response => {
          this.$modal.msgSuccess("修改成功，新密码是：" + value);
        });
      }).catch(() => {});
    },
    /** 分配角色操作 */
    handleAuthRole: function (row) {
      const userId = row.userId;
      this.$router.push("/system/user-auth/role/" + userId);
    },
    /** 提交按钮 */
    submitForm: function () {
      if (this.showTabKey == "ABC") {
        // this.$refs["formABC"].validate(valid => {
        // if (valid) {
        addAbc(this.formABC).then(response => {
          this.$modal.msgSuccess("ABC新增成功");
          this.ABCKey++;
        });
        // }
        // });
      }
      if (this.showTabKey == "D") {
        // this.$refs["formD"].validate(valid => {
        // if (valid) {
        addD(this.formD).then(response => {
          this.$modal.msgSuccess("D新增成功");
          this.DKey++;
        });
        // }
        // });
      }
      if (this.showTabKey == "E") {
        // this.$refs["formE"].validate(valid => {
        // if (valid) {
        addE(this.formE).then(response => {
          this.$modal.msgSuccess("E新增成功");
          this.EKey++;
        });
        // }
        // });
      }
      if (this.showTabKey == "F") {
        // this.$refs["formF"].validate(valid => {
        // if (valid) {
        addF(this.formF).then(response => {
          this.$modal.msgSuccess("F新增成功");
          this.FKey++;
        });
        // }
        // });
      }
      if (this.showTabKey == "G") {
        // this.$refs["formG"].validate(valid => {
        // if (valid) {
        addG(this.formG).then(response => {
          this.$modal.msgSuccess("G新增成功");
          this.GKey++;
        });

        // }
        // });
      }
      this.open = false;

    },
    /** 删除按钮操作 */
    handleDelete(row) {
      if (this.showTabKey == "ABC") {
                this.$refs.comAbc.handleBatchDelete();
            } else if (this.showTabKey == "D") {
              this.$refs.comD.handleBatchDelete();
            } else if (this.showTabKey == "E") {
              this.$refs.comE.handleBatchDelete();
            } else if (this.showTabKey == "F") {
              this.$refs.comF.handleBatchDelete();
            } else if (this.showTabKey == "G") {
              this.$refs.comG.handleBatchDelete();
            }
            // const userIds = row.userId || this.ids;
      // this.$modal.confirm('是否确认删除用户编号为"' + userIds + '"的数据项？').then(function () {
        //     return delUser(userIds);
      // }).then(() => {
        //     // this.getList();
        //     this.$modal.msgSuccess("删除成功");
      // }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('bid/abc/export', {
        ...this.queryParams
      }, `实施预算-实施_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "实施预算-投标导入";
      this.upload.open = true;
    },
    importData(file) {
      const loading = this.$loading({
        lock: true,
        text: '数据导入中...',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      let formData = new FormData();

      formData.append('file', file.file);
      return axios.post(this.upload.url + '?updateSupport=' + this.upload.updateSupport, formData, {
        headers: this.upload.headers,
        responseType: 'blob'
      }).then(res => {
        loading.close()
        this.handleFileSuccess(res, file);
      }).catch(err => {
        loading.close()
      })
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('bid/abc/importTemplate', {}, `实施预算-投标_template_${new Date().getTime()}.xlsx`)
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      if (res.data.type === 'application/json') {
        let reader = new FileReader()
        reader.readAsText(res.data);
        reader.onloadend = () => {
          let rsp = JSON.parse(reader.result);
          if (rsp.code == 200) {
            this.$modal.msgSuccess(rsp.msg);
            this.getList();
          } else {
            this.$modal.msgError(rsp.msg);
          }
        }
      } else {
        this.$modal.msgError("导入错误,请查看回执文件");
        let fileName = file.file.name;
        if (fileName.lastIndexOf(".xls") == fileName.length - 4) {
          fileName = fileName.substring(0, fileName.lastIndexOf(".xls"))
        } else if (fileName.lastIndexOf(".xlsx") == fileName.length - 5) {
          fileName = fileName.substring(0, fileName.lastIndexOf(".xlsx"))
        }
        downBlobFile(downBlobFile(res.data, fileName + "Back.xlsx"));
      }
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    /** 查询销售合同清单列表 */
    getSalecontList() {
      listSalecont(this.queryParams).then(response => {
        this.salecontList = response.rows;
      });
    },
    getChildListByPid(pid) {
      let param = {
        pid: pid
      }
      // let list = [];
      getChildListByPid(param).then(response => {
        console.log(response.data)
        if (pid == 2) {
          this.codeListA = response.data
        }
        if (pid == 3) {
          this.codeListB = response.data
        }
        if (pid == 4) {
          this.codeListC = response.data
        }
        if (pid == 5) {
          this.codeListD = response.data
        }
        if (pid == 6) {
          this.codeListE = response.data
        }
        if (pid == 9) {
          this.codeListG = response.data
        }
      });
      // return list;
},
        handleChange(value) {

            this.ids = value;
            this.multiple = !value.length

    }
  }
};
</script>
